home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / inn1.000 / inn1.4sec-linux-src.tar / inn / lib / sendarticle.c < prev    next >
C/C++ Source or Header  |  1993-01-29  |  858b  |  45 lines

  1. /*  $Revision: 1.5 $
  2. **
  3. */
  4. #include <stdio.h>
  5. #include <sys/types.h>
  6. #include "configdata.h"
  7. #include "clibrary.h"
  8. #include "libinn.h"
  9. #include "nntp.h"
  10.  
  11.  
  12. /*
  13. **  Send a string of one or more lines down a stdio FILE using RFC977
  14. **  conventions.  Return -1 on error.
  15. */
  16. int
  17. NNTPsendarticle(p, F, Terminate)
  18.     register char    *p;
  19.     register FILE    *F;
  20.     BOOL        Terminate;
  21. {
  22.     register char    *next;
  23.  
  24.     for (; p && *p; next[-1] = '\n', p = next) {
  25.     /* Get pointer to next line.  Truncate long lines. */
  26.     if ((next = strchr(p, '\n')) != NULL)
  27.         *next++ = '\0';
  28.  
  29.     /* Write line. */
  30.     if (*p == '.' && putc('.', F) == EOF)
  31.         return -1;
  32.     if (fprintf(F, "%s\r\n", p) == EOF)
  33.         return -1;
  34.  
  35.     /* Done? */
  36.     if (next == NULL)
  37.         break;
  38.     }
  39.  
  40.     if (Terminate && fprintf(F, ".\r\n") == EOF)
  41.     return -1;
  42.  
  43.     return fflush(F) == EOF || ferror(F) ? -1 : 0;
  44. }
  45.